var app = getApp();
var webhost = app.globalData.webhost;

Page({
  data: {
    id: '',
    data: {},
    dataList: [],
    reimAccCode:''
  },

  getReimTangJieDetail() {
    var that = this;
    var dataList = that.data.dataList;
    var data = that.data.data;
    var driverAccount = app.globalData.driverAccount;
    var sessionid = app.globalData.sessionid;
    var id = that.data.id;
    var parameters = [{
      String: {
        driverAccount: driverAccount,
        sessionid: sessionid,
        id: id
      }
    }];
    wx.request({
      url: webhost,
      data: {
        eap_username: "driver",
        eap_password: "Driver2018",
        boId: "tspdriver_tsp2DriverServiceBO_bo", //调用的bo
        methodName: 'getReimTangJieDetail', //调用的具体方法
        returnType: "json", //返回参数类型
        parameters: JSON.stringify(parameters)

      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      success: function(res) {
        //获取到的数据中有值为null时，将其替换成''
        var curDataList = res.data.dataList;
        var curData = res.data.data;
        if (curData){
          for (var key in curData) {
            if (curData[key] == null) {
              curData[key] = ''
            } else if (typeof (curData[key]) == 'number' && curData[key] != 0) {
              var a = curData[key].toFixed(2)
              curData[key] = a;
            }
          }
          
        }
        if (curDataList){
          for (var i = 0; i < curDataList.length; i++) {
            var b = curDataList[i].b6.toFixed(2);
            curDataList[i].b6 = b;
          }
        }
        that.setData({
          dataList: curDataList,
          data: curData
        })
      }
    })
  },

  onLoad: function(options) {
    var that = this;

    wx.setNavigationBarTitle({
      title: '趟结金额明细',
    })
    that.setData({
      id: options.id,
      reimAccCode: options.reimAccCode
    })

    that.getReimTangJieDetail()

  },

  onShow: function() {

  },

  onPullDownRefresh: function() {

  },

  onReachBottom: function() {

  },

  onShareAppMessage: function() {

  }
})